import React from 'react';
import { inject, observer } from 'mobx-react';
import { Button } from 'antd';
import { WeaDialog } from 'ecCom';
import GoalDetail from './GoalDetail'
import * as Util from "../../util/Util";

@inject('goalDetailDialogStore')
@observer
export default class GoalDetailDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            detailKey:'',
            locationkey:'',
             bttns:[],
        }
    }

    componentWillReceiveProps(nextProps){
        // if(this.props.locationkey!=nextProps.locationkey){
        //     this.setState({detailKey:nextProps.detailKey});
        //     console.log(this.state.detailKey)
        // }
        if(Util.getParams('id') && Util.getParams('id') !=''){
            let key = Util.getParams('id');
            this.setState({
                detailKey:key,
            })
        }
    }

    getButton = ()=>{
        let buttonsCreate = [
            // (<Button type="ghost" onClick={this.click.bind(this,id,'collection',)}>收藏</Button>),
            // (<Button type="ghost" onClick={this.click.bind(this)}>完成</Button>),
            // (<Button type="ghost" onClick={this.click.bind(this)}>撤销</Button>),
            // (<Button type="ghost" onClick={this.click.bind(this)}>删除</Button>),
            (<Button type="ghost" onClick={this.onlyClose}>关闭</Button>)
        ];
        return buttonsCreate;
    }


    onlyClose=()=>{
        // console.log(this.props.dialogCallBack())
        // let name = this.props.goalDetailDialogStore.detailData.name;
        // this.props.dialogCallBack(name);
        this.props.onlyClose && this.props.onlyClose();
    }

    onDialogSuccess(key,type,optparams){
        console.log(key,type,optparams)
        // if(type){
        //     if(typeof this.props.dialogCallBack === "function"){
        //        this.props.dialogCallBack(optparams);
        //     }
        // }else{
        //     this.setState({detailKey:key});
        // }
    }

    render() {
        const {detailKey} = this.state;
        let _height = window.innerHeight;
        return (
            <div className="workrelate-goal-dialogDetailDalog">
                <WeaDialog
                    visible={true}
                    title={getLabel(507890,'目标详情')}
                    icon="icon-coms-Journal"
                    iconBgcolor="#7734FF"
                    className="createWorkPlan"
                    buttons={this.getButton()}
                    style={{width: 900, height: _height}}
                    closable={true}
                    onCancel={this.onlyClose}
                >
                <GoalDetail onDialogSuccess={(key,type,optparams)=>this.onDialogSuccess(key,type,optparams)} detailKey={detailKey}  _height={_height-50} openType={'3'}/>
            </WeaDialog>
            </div>

        )
     }
}